#pragma once
#include"Mutex.hpp"

namespace CondMoudule
{
    using namespace MutexMoudle;
    class Cond
    {
    public:
        Cond()
        {
            pthread_cond_init(&_cond,nullptr);
        }
        void Wait(Mutex& lock)
        {
            pthread_cond_wait(&_cond,lock.GetMutexPtr());
        }
        void Nodify()
        {
            pthread_cond_signal(&_cond);
        }
        void NodiftAll()
        {
            pthread_cond_broadcast(&_cond);
        }
        ~Cond()
        {
            pthread_cond_destroy(&_cond);
        }
    private:
        pthread_cond_t _cond;
    };
}